#include "mypushbutton.h"
#include<QDebug>
#include<QPropertyAnimation>
/*mypushbutton::mypushbutton(QWidget *parent) : QPushButton(parent)
{

}*/
mypushbutton::mypushbutton(QString normalimg, QString pressimg)
{
    this->normalimgpath=normalimg;
    this->pressimgpath=pressimg;
    QPixmap pix;
    bool ret=pix.load(normalimg);
    if(!ret)
    {
        qDebug()<<"error";
        return;

    }
    this->setFixedSize(pix.width(),pix.height());
    this->setStyleSheet("QPushButton{border:0px;}");
    this->setIcon(pix);
    this->setIconSize(QSize(pix.width()*0.5,pix.height()*0.5));
}
void mypushbutton::zoom1(){
   QPropertyAnimation * animation=new QPropertyAnimation(this,"geometry");
   animation->setDuration(200);
   animation->setStartValue(QRect(this->x(),this->y(),this->width(),this->height()));
   animation->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
   animation->setEasingCurve(QEasingCurve::OutBounce);
   animation->start();
}
void mypushbutton::zoom2(){
    QPropertyAnimation * animation=new QPropertyAnimation(this,"geometry");
    animation->setDuration(200);
    animation->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
    animation->setEndValue(QRect(this->x(),this->y(),this->width(),this->height()));
    animation->setEasingCurve(QEasingCurve::OutBounce);
    animation->start();
}
